package com.zhdl.hardware.ranging.myantenna.repository.impl;

import com.project.command.faq.event.behavior.BehaviorPerform;
import com.zhdl.hardware.ranging.myantenna.repository.MTPortCmdHandleDao;
import com.zhdl.modules.tools.CommonCallback;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Slf4j
@Component
public class MTPortCmdHandle implements MTPortCmdHandleDao {

    @Resource
    public BehaviorPerform behaviorPerform;
    public Map<String, MTRangingCmdHandleDaoImpl> daoMap = new ConcurrentHashMap<>();


    public void addPort(String port){
        MTRangingCmdHandleDaoImpl mtRangingCmdHandleDao = new MTRangingCmdHandleDaoImpl(port,behaviorPerform);
        daoMap.put(port,mtRangingCmdHandleDao);
    }

    @Override
    public void mtRangingRun(String port, CommonCallback<byte[]> commonCallback){
        daoMap.get(port).mtRangingRun(commonCallback);
    }

}
